package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PrductionPlan;
import com.ruoyi.system.service.IPrductionPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产计划管理Controller
 * 
 * @author liukangzu
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/system/plan")
public class PrductionPlanController extends BaseController
{
    @Autowired
    private IPrductionPlanService prductionPlanService;

    /**
     * 查询生产计划管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrductionPlan prductionPlan)
    {
        startPage();
        List<PrductionPlan> list = prductionPlanService.selectPrductionPlanList(prductionPlan);
        return getDataTable(list);
    }

    /**
     * 导出生产计划管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:plan:export')")
    @Log(title = "生产计划管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrductionPlan prductionPlan)
    {
        List<PrductionPlan> list = prductionPlanService.selectPrductionPlanList(prductionPlan);
        ExcelUtil<PrductionPlan> util = new ExcelUtil<PrductionPlan>(PrductionPlan.class);
        util.exportExcel(response, list, "生产计划管理数据");
    }

    /**
     * 获取生产计划管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:plan:query')")
    @GetMapping(value = "/{prductionPlanId}")
    public AjaxResult getInfo(@PathVariable("prductionPlanId") Integer prductionPlanId)
    {
        return success(prductionPlanService.selectPrductionPlanByPrductionPlanId(prductionPlanId));
    }

    /**
     * 新增生产计划管理
     */
    @PreAuthorize("@ss.hasPermi('system:plan:add')")
    @Log(title = "生产计划管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrductionPlan prductionPlan)
    {
        return toAjax(prductionPlanService.insertPrductionPlan(prductionPlan));
    }

    /**
     * 修改生产计划管理
     */
    @PreAuthorize("@ss.hasPermi('system:plan:edit')")
    @Log(title = "生产计划管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrductionPlan prductionPlan)
    {
        return toAjax(prductionPlanService.updatePrductionPlan(prductionPlan));
    }

    /**
     * 删除生产计划管理
     */
    @PreAuthorize("@ss.hasPermi('system:plan:remove')")
    @Log(title = "生产计划管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prductionPlanIds}")
    public AjaxResult remove(@PathVariable Integer[] prductionPlanIds)
    {
        return toAjax(prductionPlanService.deletePrductionPlanByPrductionPlanIds(prductionPlanIds));
    }

    /**
     * 取消生产计划管理
     */
    @PreAuthorize("@ss.hasPermi('system:plan:cancel')")
    @Log(title = "生产计划管理", businessType = BusinessType.UPDATE)
    @PutMapping("/{prductionPlanIds}")
    public AjaxResult cancel(@PathVariable Integer[] prductionPlanIds)
    {
        return toAjax(prductionPlanService.cancelPrductionPlanByPrductionPlanIds(prductionPlanIds));
    }


}
